package wbhproject.model;

import java.net.MalformedURLException;
import java.net.URL;

/**
 * Model-class defines, what a ControllerUnit is
 * 
 * @author Thomas Aulich
 * 
 */
public class ControllerUnit {
	private long id;
	private String serverAddress;
	private String stationName;
	private String stationAlias;
	private boolean active;
	private URL readValUrl;
	private final static String TYPE_SAIA = "SAIA";

	public ControllerUnit(long pId, String pServerAddress, String pStationName,
			String pStationAlias, boolean pActive) throws MalformedURLException {
		id = pId;
		serverAddress = pServerAddress.trim();
		stationName = pStationName.trim();
		stationAlias = pStationAlias.trim();
		active = pActive;

		// Calculate URL of this ControllerUnit
		// based on the other known attributes
		readValUrl = new URL("http://" + serverAddress + "/" + stationName
				+ "/cgi-bin/readVal.exe");

	}

	public long getId() {
		return id;
	}

	public String getServerAddress() {
		return serverAddress;
	}

	public String getStationName() {
		return stationName;
	}

	public String getStationAlias() {
		return stationAlias;
	}

	public boolean getActive() {
		return active;
	}

	public URL getReadValUrl() {
		return readValUrl;
	}

	public String getUnitType() {
		return TYPE_SAIA;
	}

	public String getDescription() {
		return "Station: " + getStationName() + "; Alias: " + getStationAlias()
				+ "; Can be reached for 'readval' at: " + getReadValUrl();
	}

}
